// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.util;

public class ExecuteTimeAnalyse {
    String caption;
    ExecuteTimeAnalyse.TimeStamp[] list;
    int listIndex = 0;

    public ExecuteTimeAnalyse(String _caption, int size) {
        this.caption = _caption;
        this.list = new ExecuteTimeAnalyse.TimeStamp[size];

        for (int _int = 0; _int < size; _int++) {
            this.list[_int] = new ExecuteTimeAnalyse.TimeStamp();
        }
    }

    public void reset() {
        this.listIndex = 0;
    }

    public void add(String comment) {
        this.list[this.listIndex].time = System.nanoTime();
        this.list[this.listIndex].comment = comment;
        this.listIndex++;
    }

    public long getNanoTime() {
        return this.listIndex == 0 ? 0L : System.nanoTime() - this.list[0].time;
    }

    public int getMsTime() {
        return this.listIndex == 0 ? 0 : (int)((System.nanoTime() - this.list[0].time) / 1000000L);
    }

    public void print() {
        long _long = this.list[0].time;
        System.out.println("========== START === " + this.caption + " =============");

        for (int _int = 1; _int < this.listIndex; _int++) {
            System.out.println(_int + " " + this.list[_int].comment + ": " + (this.list[_int].time - _long) / 1000000L);
            _long = this.list[_int].time;
        }

        System.out.println("END: " + (System.nanoTime() - this.list[0].time) / 1000000L);
        System.out.println("==========  END  === " + this.caption + " =============");
    }

    static class TimeStamp {
        long time;
        String comment;

        public TimeStamp(String string) {
            this.comment = string;
            this.time = System.nanoTime();
        }

        public TimeStamp() {
        }
    }
}
